#/bin/bash

# 网安获取ap状态数据源,放在crontab执行

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

#Mysql="mysql -udev -pdev -h10.64.2.206"
Mysql="mysql -uroot -p1234-qwer -h10.64.2.21"

# 获取当前路径
workdir=$(cd $(dirname $0); pwd)

Ap_data=${workdir}/Apdata

RunLOG=${workdir}/data.log

PDir=${workdir}

# h3c设备在线ap数据获取
H3c_Ssh() {
	#/home/rduser/Netsecu/h3cap.expect $1 $2 $3 
	${workdir}/h3cap.expect $1 $2 $3 
}

# 汉明设备在线ap数据获取
hanming_Telnet() {
	${workdir}/hanming.expect $1 $2 $3 $4
}

# 广州图书馆设备数据获取
gzlib_Ssh() {
	${workdir}/gzlib.expect $1 $2 $3
}

hplib_Ssh() {
	${workdir}/hplib.expect $1 $2 $3
}

selib_Ssh() {
	${workdir}/selib.expect $1 $2 $3
}

# 返回云ac不在线ap
# 获取逻辑：请求restful接口使用关键字：Disconnect 
# 数据源ip地址：10.64.1.241:8443 
# 格式：AA:AA:AA:AA:AA:AA
idc_ruckes() {
	echo "$(date "+%F %H:%M:%S") 开始获取云AC数据" >> ${RunLOG}
	Jsession=`curl --connect-timeout 4 -i  -s -k 'https://10.64.1.241:8443/wsg/api/scg/session/login '  -X PUT  -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"userName":"admin","password":"Windfind123#@!"}' --compressed | awk -F " |;" /JSESSIONID/'{print $2}'`
	curl --connect-timeout 4 -s 'https://10.64.1.241:8443/wsg/api/scg/apsE/byZone/f77a8816-3049-40cd-8484-82919275ddc3/exportcsv?searchType=and'  -H "Cookie: ${Jsession}" --compressed --insecure | \
	awk -F',' '/Disconnect/{print $1}' | awk -F'"' '{print $2}'
	echo "$(date "+%F %H:%M:%S") 结束获取云AC数据" >> ${RunLOG}
}

# 返回经信委不在线ap 
# 获取逻辑：请求restful接口使用关键字：Disconnect 
# 数据源ip地址：10.65.0.253 
# 返回数据格式：AA:AA:AA:AA:AA:AA
jxw_ruckes() {
	echo "$(date "+%F %H:%M:%S") 开始获取经信委AC数据" >> ${RunLOG}
	Jsession_jxw=`curl --connect-timeout 4 -i -s 'https://10.65.0.253/admin/login.jsp'  --data 'url=undefined&username=admin&password=Windfind123#@!&ok=Log+In' --compressed --insecure | \awk -F " |;" '/-ejs-sessio/{print $2}'`
	curl --connect-timeout 4 -s 'https://10.65.0.253/admin/_saveexportcsv.jsp?action=exportaplist&filename=071018_14_36&searchinfo=' -H "Cookie: ${Jsession_jxw}" --compressed --insecure | \
	awk -F',' '/Disconnect/{print $1}' | awk '$1=toupper($1)'
	echo "$(date "+%F %H:%M:%S") 结束获取经信委AC数据" >> ${RunLOG}
}

# 返回环创平台不在线ap状态的route_id
# 获取逻辑：请求restful接口返回，查找关键字offline
# 格式：WIFI-481D78 AFBMRXYW
hc() {
	# 统一获取环创ap状态
	echo "$(date "+%F %H:%M:%S") 开始获取环创数据" >> ${RunLOG}
	curl --connect-timeout 10 -s "http://www.login-wifi.com/cmps/admin.php?m=Reportapiuser&a=staOnline&user=gzfxkj&password=Windfindtech123" | \
	sed -e 's/{"res":"success","info":{//g' -e 's/}}//g' -e 's/,/\n/g' | \
	awk -F'"' '/offline/{print $2}'
	echo "$(date "+%F %H:%M:%S") 结束获取环创数据" >> ${RunLOG}
}

# 返回环迅科技不在线ap状态，不分地区
# 获取逻辑：请求restful接口返回，查找关键字connectionStatus.*Disconnect
# 格式：AA:AA:AA:AA:AA:AA
hx() {
	echo "$(date "+%F %H:%M:%S") 开始获取环迅数据" >> ${RunLOG}
	curl -s -k -H "Content-Type:application/json" --data '{"secret":"igd@huanxun"}' https://p.cengcengwifi.com/portal/apstatus/igd/get | \
	sed -re "s@\{.*\:\[\{@@" -e "s@\}\]\}@@" -e 's@\}\,\{@\n@g' | \
	awk -F, '$9~/connectionStatus.*Disconnect/{print $1}' | awk -F '"' '{print $4}'
	echo "$(date "+%F %H:%M:%S") 结束获取环迅数据" >> ${RunLOG}
}

# 返回 粤剧艺术博物馆汉明ac不在线ap 
# 获取逻辑：expect请求
# 数据源ip：172.16.88.36  
# 格式：AA:AA:AA:AA:AA:AA
yishu() {
	echo "$(date "+%F %H:%M:%S") 开始获取艺术博物馆数据" >> ${RunLOG}
	hanming_Telnet '172.16.88.36' 'windfindssh' 'WFssh123#@!' 'admin' | awk -F"|" '/70/{print $3}' | sed -r 's@\ @@g'
	echo "$(date "+%F %H:%M:%S") 结束获取艺术博物馆数据" >> ${RunLOG}
}

# 返回残联现时不在线的ap
# 获取逻辑： expect到设备拿到实时在线数据与list文件对比，返回不在线ap数据
# 数据源ip地址：10.65.4.131
# 格式：AA:AA:AA:AA:AA:AA
canlian() {
	echo "$(date "+%F %H:%M:%S") 开始获取残联数据" >> ${RunLOG}
	Tmp_file=${PDir}/10.65.4.131.tmp
	List_file=${PDir}/10.65.4.131.list
	H3c_Ssh '10.65.4.131' 'windfindssh' 'WFssh123#@!' | strings |\
	awk '/ac/{print $3}' | awk '$1=toupper($1)' | sed -r 's/(\w{2})(\w{2})/\1-\2/g' | sed -e 's/-/:/g' > ${Tmp_file}
	# diff ${Tmp_file} ${List_file} | awk '/>/{print $2}'
	sort ${Tmp_file} ${List_file} | uniq -u
	echo "$(date "+%F %H:%M:%S") 结束获取残联数据" >> ${RunLOG}
}

# 返回残联现时不在线的ap
# 获取逻辑： expect到设备拿到实时在线数据与list文件对比，返回不在线ap数据
# 数据源ip地址：10.65.4.163
# 格式：AA:AA:AA:AA:AA:AA
canlianjy() {
	echo "$(date "+%F %H:%M:%S") 开始获取残联就业中心数据" >> ${RunLOG}
	Tmp_file=${PDir}/10.65.4.163.tmp
	List_file=${PDir}/10.65.4.163.list
	H3c_Ssh '10.65.4.163' 'windfindssh' 'WFssh123#@!' | strings | \
	awk '/ac/{print $3}' | awk '$1=toupper($1)' | sed -r 's/(\w{2})(\w{2})/\1-\2/g' | sed -e 's/-/:/g' > ${Tmp_file}
	# diff ${Tmp_file} ${List_file} | awk '/>/{print $2}'
	sort ${Tmp_file} ${List_file} | uniq -u
	echo "$(date "+%F %H:%M:%S") 结束获取残联就业中心数据" >> ${RunLOG}
}


# 返回广州图书馆不在线的ap
# 获取逻辑： expect到设备拿到实时在线数据与list文件对比，返回不在线ap数据
# 数据源ip地址：121.8.227.62
# 格式：AA:AA:AA:AA:AA:AA
gzlib() {
	echo "$(date "+%F %H:%M:%S") 开始获取广州图书馆数据" >> ${RunLOG}
	Tmp_file=${PDir}/121.8.227.62.tmp
	List_file=${PDir}/121.8.227.62.list
	gzlib_Ssh '121.8.227.62' 'windfindssh' 'WFssh123#@!' \
	| strings | sed -r -e 's/\[16D|---.*---//g' | \
	awk '/[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]/{print $3}' | \
	awk '$1=toupper($1)' | sed -r 's/(\w{2})(\w{2})/\1-\2/g' | sed -e 's/-/:/g' > ${Tmp_file}
	# diff ${Tmp_file} ${List_file} | awk '/>/{print $2}'
	sort ${Tmp_file} ${List_file} | uniq -u
	echo "$(date "+%F %H:%M:%S") 结束获取广州图书馆数据" >> ${RunLOG}
}


# 返回黄埔图书馆不在线的ap
# 获取逻辑： expect到设备拿到实时在线数据与list文件对比，返回不在线ap数据
# 数据源ip地址：172.16.1.32
# 格式：AA:AA:AA:AA:AA:AA
hplib() {
	echo "$(date "+%F %H:%M:%S") 开始获取黄埔图书馆数据" >> ${RunLOG}	
	Tmp_file=${PDir}/172.16.1.32.tmp
	List_file=${PDir}/172.16.1.32.list
	hplib_Ssh '172.16.1.32' 'windfindssh' 'WFssh123#@!' \
	| strings | sed -r -e 's/\[16D|---.*---//g' | \
	awk '/[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]/{print $1}' | \
	awk '$1=toupper($1)' | sed -r 's/(\w{2})(\w{2})/\1-\2/g' | sed -e 's/-/:/g' > ${Tmp_file}
	# diff ${Tmp_file} ${List_file} | awk '/>/{print $2}'
	sort ${Tmp_file} ${List_file} | uniq -u
	echo "$(date "+%F %H:%M:%S") 结束获取黄埔图书馆数据" >> ${RunLOG}	
}

# 返回少儿图书馆不在线的ap
# 获取逻辑： expect到设备拿到实时在线数据与list文件对比，返回不在线ap数据
# 数据源ip地址：192.168.136.5 
# 格式：AA:AA:AA:AA:AA:AA
selib() {
	echo "$(date "+%F %H:%M:%S") 开始获取少儿图书馆数据" >> ${RunLOG}
	Tmp_file=${PDir}/192.168.136.5.tmp
	List_file=${PDir}/192.168.136.5.list
	selib_Ssh '192.168.136.5' 'windfindssh' 'WFssh123#@!' \
	| strings | sed -r -e 's/\[16D|---.*---//g' | \
	awk '/[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]-[A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_][A-Za-z0-9_]/{print $3}' | \
	awk '$1=toupper($1)' | sed -r 's/(\w{2})(\w{2})/\1-\2/g' | sed -e 's/-/:/g' > ${Tmp_file}
	# diff ${Tmp_file} ${List_file} | awk '/>/{print $2}'
	sort ${Tmp_file} ${List_file} | uniq -u
	echo "$(date "+%F %H:%M:%S") 结束获取少儿图书馆数据" >> ${RunLOG}
}


########## 数据源获取 ##############
echo "---------开始获取数据--------------------" >> ${RunLOG}

idc_ruckes > ${Ap_data}/idc_ruckes.data &
jxw_ruckes > ${Ap_data}/jxw_ruckes.data &
hc > ${Ap_data}/hc.data &
hx > ${Ap_data}/hx.data &
yishu > ${Ap_data}/yishu.data &
canlian > ${Ap_data}/canlian.data &
canlianjy > ${Ap_data}/canlianjy.data &
gzlib > ${Ap_data}/gzlib.data &
hplib > ${Ap_data}/hplib.data &
selib > ${Ap_data}/selib.data &

wait
echo "---------开始处理数据--------------------" >> ${RunLOG}
# 判断环创或者环迅数据是否使用上一次
tmp_Phc=$(cat ${Ap_data}/hc.data)
tmp_Phx=$(cat ${Ap_data}/hx.data)
# 环创
# 查找关键字，有则用本次数据，并备份一下，没有则用上一次备份的${Ap_data}/hc.data.before
echo "$(date "+%F %H:%M:%S") 判断环创与环迅数据是否有效" >> ${RunLOG}
if [[ $(echo ${tmp_Phc} | sed -r -n "/GWIFI|WIFI/p" | wc -l) -eq 1 ]]; then
	Phc=$(cat ${Ap_data}/hc.data)
	\cp ${Ap_data}/hc.data ${Ap_data}/hc.data.before
else
	Phc=$(cat ${Ap_data}/hc.data.before)
	echo "$(date "+%F %H:%M:%S") 环创数据获取失败，本次数据为前一次备份数据" >> ${RunLOG}
fi

# 环迅
if [[ $(echo ${tmp_Phx} | sed -r -n "/\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}/p" | wc -l) -eq 1 ]]; then
	Phx=$(cat ${Ap_data}/hx.data)
	\cp ${Ap_data}/hx.data ${Ap_data}/hx.data.before
else
	Phc=$(cat ${Ap_data}/hx.data.before)
	echo "$(date "+%F %H:%M:%S") 环迅数据获取失败，本次数据为前一次备份数据" >> ${RunLOG}
fi

Pidc_ruckes=$(cat ${Ap_data}/idc_ruckes.data)
Pjxw_ruckes=$(cat ${Ap_data}/jxw_ruckes.data)
# Phc=$(cat ${Ap_data}/hc.data)
# Phx=$(cat ${Ap_data}/hx.data)
Pyishu=$(cat ${Ap_data}/yishu.data)
Pcanlian=$(cat ${Ap_data}/canlian.data)
Pcanlianjy=$(cat ${Ap_data}/canlianjy.data)
Pgzlib=$(cat ${Ap_data}/gzlib.data)
Phplib=$(cat ${Ap_data}/hplib.data)
Pselib=$(cat ${Ap_data}/selib.data)


# # 云AC
IDCtmpParm=$(echo ${Pidc_ruckes} | sed -r -e 's/ /,/g' -e "s/$/,云AC/g")
# # 经信委AC
JXWtmpParm=$(echo ${Pjxw_ruckes} | sed -r -e 's/ /,/g' -e "s/$/,经信委AC/g")
# # 环创AC
HCtmpParm=$(echo ${Phc} | sed -r -e 's/ /,/g' -e "s/$/,环创AC/g")
# # 环迅AC
HXtmpParm=$(echo ${Phx} | sed -r -e 's/ /,/g' -e "s/$/,环迅AC/g")
# # 艺术博物馆AC
YISHUtmpParm=$(echo ${Pyishu} | sed -r -e 's/ /,/g' -e "s/$/,艺术博物馆AC/g")
# # 残联AC
CANLIANtmpParm=$(echo ${Pcanlian} | sed -r -e 's/ /,/g' -e "s/$/,残联AC/g")
# # 残疾就业AC
CANLIANJYtmpParm=$(echo ${Pcanlianjy} | sed -r -e 's/ /,/g' -e "s/$/,残疾就业AC/g")
# # 广州图书馆AC
GZLIBtmpParm=$(echo ${Pgzlib} | sed -r -e 's/ /,/g' -e "s/$/,广州图书馆AC/g")
# # 黄埔图书馆AC
HPLIBtmpParm=$(echo ${Phplib} | sed -r -e 's/ /,/g' -e "s/$/,黄埔图书馆AC/g")
# # 少儿图书馆AC
SELIBtmpParm=$(echo ${Pselib} | sed -r -e 's/ /,/g' -e "s/$/,少儿图书馆AC/g")

# ########## 调试输出变量 ##########
# echo ${IDCtmpParm}
# echo ${JXWtmpParm}
# echo ${HCtmpParm}
# echo ${HXtmpParm}
# echo ${YISHUtmpParm}
# echo ${CANLIANtmpParm}
# echo ${CANLIANJYtmpParm}
# echo ${GZLIBtmpParm}
# echo ${HPLIBtmpParm}


# 进程锁
touch ${Ap_data}/ap_trap.sock

######################### 初始ap_status ####################################
## 将上一份数据清空
${Mysql} -s -N -e "TRUNCATE TABLE Light_Manager.ap_status;"
${Mysql} -s -N -e "TRUNCATE TABLE Light_Manager.ap_heartBeat;"
######################### sql语句生成与执行 ################################

######### 判断数据是否有效 #############

# ${IDCtmpParm} ${JXWtmpParm} ${HCtmpParm} ${HXtmpParm} ${YISHUtmpParm} ${CANLIANtmpParm} ${CANLIANJYtmpParm} ${GZLIBtmpParm} ${HPLIBtmpParm} ${SELIBtmpParm}

for Site_data in ${IDCtmpParm} ${JXWtmpParm} ${HCtmpParm} ${HXtmpParm} ${YISHUtmpParm} ${CANLIANtmpParm} ${CANLIANJYtmpParm} ${GZLIBtmpParm} ${HPLIBtmpParm} ${SELIBtmpParm};do
#for Site_data in ${IDCtmpParm};do
	# 将数据转成数组
	SitetmpParm=($(echo ${Site_data} | sed -r -e "s/,/ /g"))

	# 提取数据来源
	src_Site=${SitetmpParm[${#SitetmpParm[@]}-1]}

	# 提取数据主体
	SiteParm=$(echo ${SitetmpParm[@]:0:${#SitetmpParm[@]}-1})

	# 数据主体个数
	SiteParmCount=(${SiteParm})

	# echo "将数据转成数组" ${SitetmpParm[@]}
	# echo "提取数据来源" ${src_Site}
	# echo "提取数据主体" ${SiteParm}
	# echo "----------------------------------------========"

	# 判断数据来源于什么哪个AC接口	
	case ${src_Site} in
	"云AC"|"经信委AC"|"环迅AC"|"艺术博物馆AC"|"残联AC"|"残疾就业AC"|"广州图书馆AC"|"黄埔图书馆AC"|"少儿图书馆AC")	
		# echo "正在处理.." ${src_Site} >> ${RunLOG}
		if [[ $(echo ${SiteParm} | sed -r -n "/\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2}/p" | wc -l) -eq 1 ]]; then
			# 格式化sql条件
			SqlParm=$(echo ${SiteParm} | sed -r -e "s@(\w{2}:\w{2}:\w{2}:\w{2}:\w{2}:\w{2})@('\1','N')@g" -e "s/ /,/g")
			# 生成mysql
			Sql="insert into Light_Manager.ap_status(apMac,connectStatus) values${SqlParm};"
			# 执行mysql写库
			${Mysql} -s -N -e "${Sql}"
			# 写日志
			if [[ $? -eq 0 ]]; then
				echo "$(date "+%F %H:%M:%S") ${src_Site}数据写入成功,条数为${#SiteParmCount[@]}" >> ${RunLOG}
				# 插入条数
				${Mysql} -s -N -e "insert into Light_Manager.ap_heartBeat values('${src_Site}',${#SiteParmCount[@]});"
			else
				echo "$(date "+%F %H:%M:%S") ${src_Site}数据写入失败" >> ${RunLOG}
			fi
		else
			echo "$(date "+%F %H:%M:%S") ${src_Site}数据获取失败或没有ap下线,条数为${#SiteParmCount[@]}" >> ${RunLOG}
			# 插入条数
			${Mysql} -s -N -e "insert into Light_Manager.ap_heartBeat values('${src_Site}',${#SiteParmCount[@]});"
		fi
		;;
	"环创AC")
		# echo "正在处理.." ${src_Site} >>${RunLOG}
		if [[ $(echo ${SiteParm} | sed -r -n "/GWIFI|WIFI/p" | wc -l) -eq 1 ]]; then
			# 格式化sql条件
			SqlParm=$(echo ${SiteParm} | sed -r -e "s/ /','N'),('/g" -e "s/^/('/g" -e "s/$/','N')/g")
			# 生成mysql
			Sql="insert into Light_Manager.ap_status(radiusLocation,connectStatus) values${SqlParm};"
			# 执行mysql写库
			${Mysql} -s -N -e "${Sql}"
			# 写日志			
			if [[ $? -eq 0 ]]; then
				echo "$(date "+%F %H:%M:%S") ${src_Site}数据写入成功,条数为${#SiteParmCount[@]}" >> ${RunLOG}
				# 插入条数
				${Mysql} -s -N -e "insert into Light_Manager.ap_heartBeat values('${src_Site}',${#SiteParmCount[@]});"
			else
				echo "$(date "+%F %H:%M:%S") ${src_Site}数据写入失败" >> ${RunLOG}
			fi
		else
			echo "$(date "+%F %H:%M:%S") ${src_Site}数据获取失败或没有ap下线,条数为${#SiteParmCount[@]}" >> ${RunLOG}
			# 插入条数
			${Mysql} -s -N -e "insert into Light_Manager.ap_heartBeat values('${src_Site}',${#SiteParmCount[@]});"
		fi
		;;
	*)
		echo "传入的场点ap数据 ${src_Site} 来源不在定义范围内" >> ${RunLOG}
		;;
	esac
done

## 根据radiusLocation更新ap Mac
echo "$(date "+%F %H:%M:%S") 开始根据radiusLocation更新ap Mac" >> ${RunLOG}
${Mysql} -s -N -e "UPDATE  Light_Manager.ap_status s LEFT JOIN Light_Manager.location l on s.radiusLocation = l.radiusLocation LEFT JOIN Light_Manager.ap a on l.id = a.locationID SET s.apMac = a.mac where s.radiusLocation is not null;"
if [[ $? -eq 0 ]]; then
	echo "$(date "+%F %H:%M:%S") radiusLocation更新ap Mac数据写入成功" >> ${RunLOG}
fi


## 根据apMac 更新其余字段信息
echo "$(date "+%F %H:%M:%S") 根据apMac 更新其余字段信息" >> ${RunLOG}
#${Mysql} -s -N -e " UPDATE Light_Manager.ap_status s LEFT JOIN Light_Manager.ap a on s.apMac = a.mac LEFT JOIN  Light_Manager.location l on a.locationID = l.id SET s.locationID = a.locationID,s.locationName = l.name,s.producer = a.producer,s.installPosition = a.installPosition,s.city = l.city WHERE lastest = 'Y';"
${Mysql} -s -N -e "UPDATE Light_Manager.ap_status s LEFT JOIN Light_Manager.ap a on s.apMac = a.mac LEFT JOIN  Light_Manager.location l on a.locationID = l.id left join Light_Manager.LocationCodeMapping m on replace(a.mac,':','') = m.mac SET s.locationID = a.locationID,s.locationName = l.name,s.producer = a.producer,s.installPosition = a.installPosition,s.city = l.city,s.locationCode = m.locationCode;"

if [[ $? -eq 0 ]]; then
	echo "$(date "+%F %H:%M:%S") 根据apMac 更新其余字段信息数据写入成功" >> ${RunLOG}
fi

## 更新另一个表
echo "$(date "+%F %H:%M:%S") 统计+1那个表" >> ${RunLOG}
${Mysql} -s -N -e "SET @reportdate = CURDATE();update Light_Manager.ap_connectRecord set connectSuccess = connectSuccess + 1 where cal_dt = @reportdate;"
if [[ $? -eq 0 ]]; then
	echo "$(date "+%F %H:%M:%S") 统计+1那个表数据写入成功" >> ${RunLOG}
fi

echo "$(date "+%F %H:%M:%S") 统计-1那个表" >> ${RunLOG}
${Mysql} -s -N -e "SET @reportdate = CURDATE();update Light_Manager.ap_connectRecord set connectSuccess = connectSuccess -1 where apMac in (select replace(apMac,':','') apMac from Light_Manager.ap_status) and cal_dt = @reportdate;"
if [[ $? -eq 0 ]]; then
	echo "$(date "+%F %H:%M:%S") 统计-1那个表数据写入成功" >> ${RunLOG}
fi

echo "$(date "+%F %H:%M:%S") 执行网安数据存储过程" >> ${RunLOG}
${Mysql} -s -N -e "call Light_Manager.netSecurity_heartbeat();"
echo "$(date "+%F %H:%M:%S") 提交网安数据存储过程结束" >> ${RunLOG}

# 解除锁
rm -f ${Ap_data}/ap_trap.sock
# 执行结束
echo "---------数据处理结束--------------------" >> ${RunLOG}
echo "============================================================================" >> ${RunLOG}
